<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_items', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('自增id');
            $table->bigInteger('order_id')                  ->default(0)->comment('订单id');
            $table->bigInteger('user_id')                   ->default(0)->comment('用户id');
            $table->string('item_num')                      ->nullable()      ->comment('子订单编号');
            $table->bigInteger('course_id')                 ->default(0)->comment('课程id');
            $table->decimal('original_price')               ->default(0)->comment('商品原始单价');
            $table->decimal('discount_price')               ->default(0)->comment('商品优惠后单价');
            $table->integer('num')                          ->default(0)->comment('购买数量');
            $table->decimal('total_amount')                 ->default(0)->comment('实际成交总价格');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_items');
    }
}
